package cn.panda.edu.service.impl;

import cn.panda.edu.dao.ThesisLayoutMapper;
import cn.panda.edu.model.ThesisLayout;
import cn.panda.edu.service.ThesisLayoutService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ThesisLayoutServiceImpl implements ThesisLayoutService {
	
	@Autowired
    ThesisLayoutMapper thesisLayoutMapper;

	@Override
	public int deleteByPrimaryKey(Integer thesisLayoutId) {
		// TODO Auto-generated method stub
		return thesisLayoutMapper.deleteByPrimaryKey(thesisLayoutId);
	}

	@Override
	public int insert(ThesisLayout record) {
		// TODO Auto-generated method stub
		return thesisLayoutMapper.insert(record);
	}

	@Override
	public int insertSelective(ThesisLayout record) {
		// TODO Auto-generated method stub
		return thesisLayoutMapper.insertSelective(record);
	}

	@Override
	public ThesisLayout selectByPrimaryKey(Integer thesisLayoutId) {
		// TODO Auto-generated method stub
		return thesisLayoutMapper.selectByPrimaryKey(thesisLayoutId);
	}

	@Override
	public int updateByPrimaryKeySelective(ThesisLayout record) {
		// TODO Auto-generated method stub
		return thesisLayoutMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(ThesisLayout record) {
		// TODO Auto-generated method stub
		return thesisLayoutMapper.updateByPrimaryKey(record);
	}

	/**
	 * 
	* @Title: listAll 
	* @Description: 学生段查看论文规范
	* @param pageIndex
	* @param pageSize
	* @param record
	* @return  
	* PageInfo<ThesisLayout>
	 */
	@Override
	public PageInfo<ThesisLayout> listAll(int pageIndex, int pageSize, ThesisLayout record){
		// TODO Auto-generated method stub
		Page<ThesisLayout> plist = PageHelper.startPage(pageIndex, pageSize);
		thesisLayoutMapper.listAll(record);
		PageInfo<ThesisLayout> pageinfo = new PageInfo<>(plist);
		return pageinfo;
	}

	@Override
	public PageInfo<ThesisLayout> selectLikeByPageSelective(Integer thesisLayoutId, String thesisLayoutName, Integer pageIndex,
                                                            Integer pageSize) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("thesisLayoutId", thesisLayoutId);
		map.put("thesisLayoutName", thesisLayoutName);
		PageHelper.startPage(pageIndex, pageSize);
		List<ThesisLayout> tList = thesisLayoutMapper.selectLikeByPageSelective(map);
		PageInfo<ThesisLayout> pageInfo = new PageInfo<>(tList);
		return pageInfo;
	}

}
